#ifndef _FILEHANDLE_H
#define _FILEHANDLE_H

#include <stdio.h>
#include <string.h>
#include "input_struc.h"
#include "hdf.h"

#define FMT_L1HDF      1
#define FMT_L2HDF      2
#define FMT_MOSL1B     3
#define FMT_SEAWIFSL1A 4
#define FMT_OCTSL1B    5
#define FMT_OCTSL1A    6
#define FMT_OSMIL1A    7
#define FMT_MODISL1B   8
#define FMT_CZCSL1A    9
#define FMT_L1XCAL     10
#define FMT_L2VAL      11
#define FMT_MSL12L2    12
#define FMT_HMODISL1B  13
#define FMT_MODISGEO   14
#define FMT_CLASSAVHRR 15
#define FMT_OCML1B     16
#define FMT_OCML1BDB   17
#define FMT_MERISL1B   18
#define FMT_MERISL2    19
#define FMT_L3BIN      20
#define FMT_VIIRSL1B   21
#define FMT_VIIRSGEO   22
#define FMT_OCM2L1B    23
#define FMT_MERISCC    24
#define FMT_L2NCDF     25

#define FORWARD      0
#define INVERSE_ZERO 1
#define INVERSE_NLW  2
#define INVERSE_LW   3


#define READ  0
#define WRITE 1

static char sensorName[][20] =
  {"SeaWiFS",
   "MOS",
   "OCTS",
   "AVHRR",
   "OSMI",
   "MODIST",
   "MODISA",
   "CZCS",
   "HMODIST",
   "HMODISA",
   "OCM1",
   "OCM2",
   "MERIS",
   "MERIS",
   "VIIRSN",
   "OCRVC"};

static char sensorDir[][20] =
  {"seawifs",
   "mos",
   "octs",
   "avhrr",
   "osmi",
   "modist",
   "modisa",
   "czcs",
   "hmodist",
   "hmodisa",
   "ocm1",
   "ocm2",
   "meris",
   "meris",
   "viirsn",
   "ocrvc"};

static char sensorSub[][20] =
  {"seawifs_gac",
   "seawifs_lac",
   "modisa",
   "hmodisa",
   "modist",
   "hmodist"};
//zhelishi shuju jiegou
typedef struct filehandle_struct {
    char      name[FILENAME_MAX];
    int32_t   format;
    int32_t   sensorID;
    int32_t   subsensorID;
    int       modis_subset_compat; /* force modis file to be read as subsetted */
    int32_t   length;
    int32_t   spix;                /* start pixel (0-based)                  */
    int32_t   epix;                /* end pixel (0-based)                    */
    int32_t   dpix;                /* pixel sub-sampling increment           */
    int32_t   npix;
    int32_t   ctl_pt_incr;
    int32_t   nscan;
    int32_t   nbands;
    int32_t   nbandsir;
    int32_t   *bindx;              /* index to closest seawifs band          */
    int32_t   ndets;
    int32_t   mode;
    char      l2prod[PRODSTRLEN];  /* list of L2 products to be included     */
    char      def_l2prod[PRODSTRLEN];  /* list of default L2 products      */
    int32_t   sd_id;               /* hdf file id for the opened output file */
    int32_t   tot_prod;            /* total # of L2 products to be created   */
    char      l2_prod_names[MAXPROD][32];
    char      *pro_control;
    char      *input_parms;
    char      *input_files;
    char      *mask_names;
    instr     *input;
    int       percent_cloud;
    int       percent_land;
    int       percent_water;
    char      *calfile;
    char      *geofile;
    float     orbit_node_lon;
    int32_t   orbit_number;
    char      node_crossing_time[32];
    int32_t   flag_cnt[NFLAGS];
    int32     n_inprods;
    int32_t   terrain_corrected;
    int32_t   sv_with_moon;
    int32_t   ocrvc_opt;
    int32_t   grp_id[5];
} filehandle;

#endif
